package routers

import (
	"beeblog/controllers"
	"os"

	"github.com/astaxie/beego"
)

func init() {
	beego.SetLevel(beego.LevelInformational)
	beego.Router("/", &controllers.MainController{})
	beego.Router("/hello", &controllers.HelloController{})
	beego.Router("/login", &controllers.LoginController{})
	beego.Router("/category", &controllers.CategoryController{})
	beego.Router("/topic", &controllers.TopicController{}) //只会识别http的默认方法Get,Post等
	//自动路由，url的访问：topic/get,topic/post,topic/add等
	//struct的名称的后缀必须为Controller
	beego.AutoRouter(&controllers.TopicController{})
	//"post:Add"的方式指定路由"/reply/add"的post请求到ReplyController.Add方法。不同请求路由到不同方法的用法："post:Add;get:Get"
	beego.Router("/reply/add", &controllers.ReplyController{}, "post:Add")
	beego.Router("/reply/delete", &controllers.ReplyController{}, "get:Delete")
	beego.Router("/reply", &controllers.ReplyController{})
	// beego.AutoRouter(&controllers.ReplyController{})

	//附件
	//创建附件目录
	os.Mkdir("attachment", os.ModePerm)

	// 作为静态文件
	// beego.SetStaticPath("/attachment", "attachment")

	//作为一个单独的控制器来处理
	beego.Router("/attachment/:all", &controllers.AttachController{})
}
